home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_deadlysight.cog < prev    next >
Text File  |  1998-02-25  |  6KB  |  224 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_DEADLYSIGHT.COG
  4. #
  5. # FORCEPOWER Script - Deadly Sight
  6. #  Dark Side Bonus Power
  7. #  Bin 34
  8. #
  9. # [YB]
  10. #
  11. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  12.  
  13.  
  14. symbols
  15.  
  16. thing       player                           local
  17. thing       victim                           local
  18.  
  19. flex        cost=300.0                       local
  20. flex        mana                             local
  21. flex        limit                            local
  22. flex        count                            local
  23. flex        damage                           local
  24. flex        starthealth                      local
  25. int         rank                             local
  26. int         oldlight                         local
  27. int         retval=0                         local
  28.  
  29. sound       deadlySound=ForceDSight01.WAV    local
  30. sound       deadlySound2=ForceDSight02.WAV   local
  31. int         channel=-1                       local
  32.  
  33. template    smoke_tpl=+heavysmoke            local
  34. int         smoke                            local
  35.  
  36. int         inbubble=0                       local
  37.  
  38. message     startup
  39. message     activated
  40. message     pulse
  41. message     newplayer
  42. message     killed
  43. message     selected
  44. message     enterbubble
  45. message     exitbubble
  46. message     user0
  47.  
  48. end
  49.  
  50. # ========================================================================================
  51.  
  52. code
  53.  
  54. startup:
  55.    player = GetLocalPlayerThing();
  56.    inbubble = 0;
  57.  
  58.    oldlight = GetThingLight(player);
  59.    call stop_power;
  60.  
  61.    Return;
  62.  
  63. # ........................................................................................
  64.  
  65. activated:
  66.    // Cannot use power if blinded
  67.    if(GetActorFlags(player) & 0x800) Return;
  68.  
  69.    if(IsInvActivated(player, 34)) Return;
  70.  
  71.    if(inbubble) Return;
  72.  
  73.    mana = GetInv(player, 14);
  74.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  75.    {
  76.       SetInvActivated(player, 34, 1);
  77.       if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  78.  
  79.       // Send a "force disturbance"...
  80.       if(!IsMulti())
  81.          SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 34, 0, 0, 0);
  82.  
  83.       rank = GetInv(player, 34);
  84.  
  85.       PlayMode(player, 24);
  86.  
  87.       // Play activation sound
  88.       PlaySoundThing(deadlySound, player, 1.0, -1, -1, 0x80);
  89.  
  90.       // Play loop sound at 0.0 volume and fade it in to 1.0 volume in 0.75 secs
  91.       channel = PlaySoundThing(deadlySound2, player, 0.0, -1, -1, 0x81);
  92.       ChangeSoundVol(channel, 1.0, 0.75);
  93.  
  94.       // make him a dynamic light too
  95.       oldlight = GetThingLight(player);
  96.       SetThingLight(player, 1.0, 1.0);
  97.  
  98.       count = 0;
  99.       limit = 3 * rank;
  100.  
  101.       starthealth = GetThingHealth(player);
  102.  
  103.       SetPulse(0.5);
  104.    }
  105.  
  106.    Return;
  107.  
  108. # ........................................................................................
  109.  
  110. pulse:
  111.    count = count + 1;
  112.    if((count > limit) || (GetThingHealth(player) < starthealth) || (GetActorFlags(player) & 0x800))
  113.    {
  114.       call stop_power;
  115.       Return;
  116.    }
  117.  
  118.    victim = FirstThingInView(player, 20 + 15 * rank, 2 + rank, 0x404);
  119.    while(victim != -1)
  120.    {
  121.       if(
  122.          HasLOS(player, victim) &&
  123.          (victim != player) &&
  124.          !(GetThingFlags(victim) & 0x200) &&
  125.          !(GetActorFlags(victim) & 0x100) &&
  126.          !((jkGetFlags(victim) & 0x20) && !IsInvActivated(player, 23)) &&
  127.          (jkGetBubbleDistance(victim) > 1.0)
  128.         )
  129.       {
  130.          if(GetThingType(victim) == 10)      // OTHER PLAYER
  131.          {
  132.             if(!(GetThingFlags(victim) & 0x200))
  133.             {
  134.                retval = SkillTarget(victim, player, 34, rank);
  135.  
  136.                if(victim != -1)
  137.                   ChangeSoundVol(channel, 1.0, 0.1);
  138.                else
  139.                   ChangeSoundVol(channel, 0.0, 0.1);
  140.  
  141.                if(GetCurrentCamera() == 0) AddDynamicTint(player, 0.15, 0.0, 0.07);
  142.             }
  143.  
  144.          }
  145.          else                                // ENEMY
  146.          {
  147.             if(!BitTest(GetActorFlags(victim), 0x100))
  148.             {
  149.                damage = SkillTarget(victim, player, 34, 0) * (rank / 2);
  150.                if(damage > 0)
  151.                {
  152.                   DamageThing(victim, damage, 0x8, player);
  153.                   smoke = CreateThingAtPos(smoke_tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  154.  
  155.                   if(victim != -1)
  156.                      ChangeSoundVol(channel, 1.0, 0.1);
  157.                   else
  158.                      ChangeSoundVol(channel, 0.0, 0.1);
  159.  
  160.                   if(GetCurrentCamera() == 0)
  161.                      AddDynamicTint(player, 0.15, 0.0, 0.07);
  162.                }
  163.             }
  164.          }
  165.       }
  166.       victim = NextThingInView();
  167.    }
  168.  
  169.    Return;
  170.  
  171. # ........................................................................................
  172.  
  173. selected:
  174.    jkPrintUNIString(player, 34);
  175.    Return;
  176.  
  177. # ........................................................................................
  178.  
  179. killed:
  180.    if(GetSenderRef() != player) Return;
  181.  
  182. newplayer:
  183.    call stop_power;
  184.  
  185.    Return;
  186.  
  187. # ........................................................................................
  188.  
  189. enterbubble:
  190.    inbubble = 1;
  191.    call stop_power;
  192.    Return;
  193.  
  194. # ........................................................................................
  195.  
  196. exitbubble:
  197.    inbubble = 0;
  198.    Return;
  199.  
  200. # ........................................................................................
  201.  
  202. user0:
  203.    call stop_power;
  204.    Return;
  205.  
  206. # ........................................................................................
  207.  
  208. stop_power:
  209.    if(channel != -1)
  210.    {
  211.       StopSound(channel, 0.1);
  212.       channel = -1;
  213.    }
  214.  
  215.    SetPulse(0);
  216.    SetThingLight(player, oldlight, 0.0);
  217.    SetInvActivated(player, 34, 0);
  218.  
  219.    Return;
  220.  
  221. end
  222.  
  223.  
  224.